<?
set_include_path('./../../nearestCaches/library' . PATH_SEPARATOR . get_include_path());
require 'functions.php';
$lang = getLang();
if ($_GET['kml'] == '') {
	echo '<?xml version="1.0" encoding="utf-8" ?>
		<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
		<html xmlns="http://www.w3.org/1999/xhtml" xmlns:locify="http://client.locify.com/locify_ns/1.0" xml:lang="en" lang="en">
		<head>
    		<title>'.$lang['waypoint'].'</title>
  		</head>
  		<body class="form">
    		<form action="'.SERVICE_URL.'waypoint_navigate.php?kml=1" method="post">
		<fieldset>
			<b>'.$lang['latitude'].':</b> <br />
				<label>deg <input type="text" name="lat"  size="2" value="'.$_GET['lat'].'"></label><br />
				<label>min <input type="text" name="lat_min"  size="3" value="'.$_GET['lat_min'].'"></label><br />
				<label>sec <input type="text" name="lat_sec"  size="3" value="'.$_GET['lat_sec'].'"></label>
				<br />
			<label><b>'.$lang['longitude'].':</b> <br />
				<label>deg <input type="text" name="lon"  size="2" value="'.$_GET['lon'].'"></label><br />
				<label>min <input type="text" name="lon_min"  size="3" value="'.$_GET['lon_min'].'"></label><br />
				<label>sec <input type="text" name="lon_sec"  size="3" value="'.$_GET['lon_sec'].'"></label>
				<br />
         		<input type="submit" value="'.$lang['view_and_navigate'].'" /><br />
         		<label>'.$lang['name'].': 
         			<input type="text" name="name"  size="6" value="'.$_GET['name'].'">
         		</label><br />
         		<label>'.$lang['description'].': 
         			<input type="text" name="desc"  size="6" value="'.$_GET['desc'].'">
         		</label><br />
		</fieldset>
    		</form>
  		</body>
		</html>';
} else {
	if (($_POST["lat"] <> '') AND ($_POST["lon"] <> '')) {
		header('Location: '.SERVICE_URL.'wp_kml.php?lat='.convert($_POST["lat"], convert($_POST["lat_min"], $_POST["lat_sec"])).'&lon='.convert($_POST["lon"], convert($_POST["lon_min"], $_POST["lon_sec"])).'&name='.urlencode($_POST["name"]).'&desc='.urlencode($_POST["desc"]));
	} else {
		header('Location: '.SERVICE_URL.'waypoint_navigate.php?lat='.$_POST["lat"].'&lat_min='.$_POST["lat_min"].'&lat_sec='.$_POST["lat_sec"].'&lon='.$_POST["lon"].'&lon_min='.$_POST["lon_min"].'&lon_sec='.$_POST["lon_sec"].'&name='.urlencode($_POST["name"]).'&desc='.urlencode($_POST["desc"]));
	}
}
?>
